
 /**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2017-2027 Chinazyjr,Inc.All Rights Reserved.
 */
package com.sys.midware.redis.core.operation.impl;

/**
 * <b>Description：</b> TODO <br/>
 * <b>ClassName：</b> DefaultTuple <br/>
 * <b>@author：</b> jackyshang <br/>
 * <b>@date：</b> 2016年8月23日 下午8:43:21 <br/>
 * <b>@version: </b>  <br/>
 */
public class ZSetTuple<V> {
    private final Double score;
    private final V value;
    
    /**
     * Constructs a new <code>DefaultTuple</code> instance.
     * 
     * @param value
     * @param score
     */
    public  ZSetTuple(V value, Double score) {
        this.score = score;
        this.value = value;
    }

    /**
     * value
     *
     * @return  the value
     */
    
    public V getValue() {
        return value;
    }

    /**
     * score
     *
     * @return  the score
     */
    
    public Double getScore() {
        return score;
    }



    @SuppressWarnings("unchecked")
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (!(obj instanceof ZSetTuple))
            return false;
        ZSetTuple<V> other = (ZSetTuple<V>) obj;
        if (score == null) {
            if (other.score != null)
                return false;
        } else if (!score.equals(other.score))
            return false;
        if (!value.equals(other.value))
            return false;
        return true;
    }

    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((score == null) ? 0 : score.hashCode());
        result = prime * result + ((value == null) ? 0 : value.hashCode());
        return result;
    }

    public int compareTo(Double o) {
        Double d = (score == null ? Double.valueOf(0.0d) : score);
        Double a = (o == null ? Double.valueOf(0.0d) : o);
        return d.compareTo(a);
    }

}
